package com.num2.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.num2.form.DemoForm;
import com.num2.model.DemoModel;
import com.num2.service.DemoService;

@Controller
@RequestMapping("/demo")
public class DemoCtrl {

    @Resource
    private DemoService demoService;

    @RequestMapping("/login")
    public String Login(DemoForm loginForm,Model m){

        DemoModel demoModel = demoService.login(loginForm);
        if (demoModel != null) {
            m.addAttribute("id", demoModel.getId());
            m.addAttribute("sex", demoModel.getSex());
            return "demo/welcome";
        }else {
            return "demo/error";
        }
    }

	public DemoService getDemoService() {
		return demoService;
	}

	public void setDemoService(DemoService demoService) {
		this.demoService = demoService;
	}

}